#include <iostream>
#include <math.h>
using namespace std;
const int inf=0x7fffffff;

int main(){
	int n;
	cin>>n;
	int a[n+1],dp[n+1];
	for(int i=1;i<=n;i++)
		dp[i] = inf;
	dp[0] = -1;
	a[0] = -1;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i;j++)
			dp[j] = min(dp[j],dp[j-1] < a[i]?a[i]:inf);
	for(int i=n;i>=0;i--)
		if(dp[i] != inf){
			cout<<i;
			break;
		}
	return 0;
}
